clear;close all;
[Q,A,F]=Spara2QandA([2 1 4 3 6 7 5],[10:5:40],[1.1 1.3],'Y','CMT',0,-1);
close all;
% A=A(200:800,:);
% F=F(200:800,:);
W = (F-1.2268)*2*pi;
W1 = (F-1.223)*2*pi;
W2 = (F-1.224)*2*pi;
W3 = (F-1.2252)*2*pi;
W4 = (F-1.2268)*2*pi;
W5 = (F-1.2288)*2*pi;
W6 = (F-1.231)*2*pi;
W7 = (F-1.2336)*2*pi;

syms omega
f=fittype('4*gr*gd/((omega)^2+(gr+gd)^2)','independent','omega','coefficients',{'gr','gd'});
options = fitoptions(f);
options.StartPoint=[0.000000001 0.000000001];
cfun = fit(W,A(:,4),f,options);

% YW_Plot_Fast({F,A(:,4),F,cfun(W),F,4*0.00548^2./(W.^2+4*0.00548^2)})
% Origin = 4*0.00548^2./(W.^2+4*0.00548^2);
% YW_Plot_Fast({F,A(:,4),F,Origin});
Y1=A(:,1);
Y2=A(:,2);
Y3=A(:,3);
Y4=A(:,4);
Y5=A(:,5);
Y6=A(:,6);
Y7=A(:,7);

WA = [W1,Y1,W2,Y2,W3,Y3,W4,Y4,W5,Y5,W6,Y6,W7,Y7];
createFit(W1, Y1)
createFit(W2, Y2)
createFit(W3, Y3)
createFit(W4, Y4)



